package com.zlf.config;

import com.alibaba.cloud.commons.lang.StringUtils;
import com.alibaba.csp.sentinel.adapter.spring.webmvc.callback.UrlCleaner;
import org.springframework.stereotype.Component;

/**
 * 防止 /urlCleaner/{id} 这样的请求地址导致限流认为不是一个请求。
 */
@Component
public class MyCleaner implements UrlCleaner {

    @Override
    public String clean(String s) {
        if (StringUtils.isBlank(s)) {
            return s;
        }
        if (s.startsWith("/urlCleaner/")) {
            return "/urlCleaner/*";
        }
        return s;
    }
}
